<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工信息管理</title>
<%@ include file="../../common/Style.jsp"%>

<script>
var dataGrid ;
$(document).ready(function(){
	
	parent.$.messager.progress('close'); 
	
	var params = "";

	dataGrid = $('#dataGrid').datagrid({
		url : 'headQSupplierMgmtJSONAction!listSupplierTagData',
		queryParams: params,
		fit : true,
		border : false,
		pagination : true,
		pageSize : 25,
		pageList : [ 25, 30],		
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect:false,
		nowrap : false,
		rownumbers : true,
		sortName : 'status',
		sortOrder : 'asc',
		columns : [ [
 		    {
				field : 'id',
				title : '供应商账号',
				width : 70
			},{	
				field : 'name',
				title : '供应商名字',
				width : 170
				
			},{	
				field : 'tags',
				title : '供应商标签',
				width : 170			
			},{	
				field : 'phone',
				title : '电话',
				width : 270			
			},{	
				field : 'initialAcctBalance',
				title : '金额',
				width : 170				
			},{	
				field : 'address',
				title : '地址',
				width : 280
			}]],
		toolbar : '#toolbar',
	});

	
});



function insertSupplierTags(){

	var rows = dataGrid.datagrid('getSelections');
	var param = "";
	if(rows.length>0){
		for(let index=0;index < rows.length; index++){
			param = param+"formBean.ids=" + rows[index].id+"&"			
		}
		var tagId = $("#tagId").val();
		
		if(tagId ==0){
			$.messager.alert('提示','请选择供应商需要添加的标签！');
		}else{
			var params = param+ "formBean.tagId=" + tagId + "&formBean.type=0"
			window.location.href = 'headQSupplierMgmtJSPAction!saveOrDeleteTag?' + params;
		}
	}  else {
		$.messager.alert('提示','供应商信息为空,请选择要添加的供应商！');
	}
	
}

function clearSupplierTags(){
	var rows = dataGrid.datagrid('getSelections');

	var param = "";
	if(rows.length>0){
		for(let index=0;index < rows.length; index++){
			param = param+"formBean.ids=" + rows[index].id+"&"			
		}
		var tagId = $("#tagId").val();
		if(tagId ==0){
			$.messager.alert('提示','请选择供应商需要删除的标签！');
		}else{
			var params = param+ "formBean.tagId=" + tagId + "&formBean.type=1"
			window.location.href = 'headQSupplierMgmtJSPAction!saveOrDeleteTag?' + params;
		}		
	} else {
		$.messager.alert('提示','供应商信息为空,请选择要修改的供应商！');
	}
	
}

function findSupplier(){
	dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
}


</script>

</head>
<body>
	
	<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'north',border:false" style="height: 35px; overflow: hidden;">
			<form id="searchForm" name="searchForm" method="post">
				<strong>供应商姓名:</strong> <input type="text"  style="width:120px" class="easyui-textbox" value="" name="formBean.supplierName" id="name" placeholder="可以模糊查询供应商名字" /> <strong>标签:</strong>
				<s:select size="1" cssClass="easyui-combobox" style="width:120px" id="tagId" list="uiBean.tags" listKey="id" name="formBean.tagId" listValue="tagName" />

				<a onclick="insertSupplierTags();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-add',plain:true">批量添加供应商标签</a> <a
					onclick="findSupplier();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true">根据标签查找供应商</a> <a
					onclick="clearSupplierTags();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-cancel',plain:true">批量清空供应商标签</a>

			</form>
		</div>

		<div data-options="region:'center',border:false">
			<table id="dataGrid"></table>
	    </div>
	
	</div>
	
</body>
</html>